<script setup lang="ts">
import { onMounted, ref } from "vue"
import { CommentApi, OrganizationApi, ContactApi } from "@/api/crm"
import router from "@/router"
defineOptions({
  name: "Organization"
})

const organizationList = ref()
const organizationListInfo = ref({
  total: 0,
  pageSize: 0,
  currentPage: 1
})
const getOrganizationList = async () => {
  let resp = await OrganizationApi.getOrganizationPageList()
  organizationList.value = resp.data.result
  let { total, pageSize, currentPage } = resp.data
  organizationListInfo.value = {
    total,
    pageSize,
    currentPage
  }
}

const goDetail = (id: string) => {
  // console.log(scope);
  router.push({ path: "/crm/organization/detail", query: { id } })
}
onMounted(() => {
  getOrganizationList()
})
</script>

<template>
  <div class="layout-container">
    <el-card>
      <el-button type="primary" @click="">添加</el-button>
    </el-card>
    <el-card style="margin-top: 15px">
      <el-table :data="organizationList">
        <el-table-column type="index" label="序号" width="80"></el-table-column>
        <el-table-column label="全称">
          <template #default="scope">
            <el-link type="primary" @click="goDetail(scope.row._id)">{{ scope.row.fullname }}</el-link>
          </template>
        </el-table-column>
        <el-table-column prop="category" label="公司类型"></el-table-column>
      </el-table>
      <!-- 翻页功能 -->
      <el-pagination
        :total="organizationListInfo.total"
        :current-page="organizationListInfo.currentPage"
        :page-size="organizationListInfo.pageSize"
        @current-change=""
        layout="prev, pager, next,->,total"
      ></el-pagination>
    </el-card>
  </div>
</template>

<style lang="scss" scoped></style>
